#ifndef __SQL_FUNC_H__
#define __SQL_FUNC_H__

typedef struct
{
    char *ip;
    char *mac;
} FastConbleGatewayList;


typedef struct
{
    char *mtag;
    int validTime;
    char *updateTime;
    char *devqueryTime;
    char *familyId;
} FastConbleDataInfo;

typedef struct
{
    char *did;
    char *pid;
    char *devname;
    char *room;
    int roomId;
    int devicetypeflag;
    int ignoreflag;
    char *version;
    char *extendInfo;
    int terminalid;
    char *aeskey;
    char *shortaddr;
    char *bletoken;
    char *sdid;
} FastConbleDevlist;

typedef struct {
    int roomId;
    char *roomName;
} FastConbleFamilyInfoRoomlist;

typedef struct {
    int groupId;
    char* groupName;
    int roomId;
    char* roomName;
    char* blecatetory;
    int ignoreflag;
} FastConbleGroupList;

typedef struct {
    char* name;
    char* room;
    int roomId;
    char* image;
    int backColor;
    char* bletoken;
    char* moduleid;
    int ignoreflag;
} FastConbleSceneList;

typedef struct {
    char* moduleid;
    char* sdid;
    char* content;
    char* did;
} FastConbleSceneListModuleDev;

int SqlInsertGatewayList(FastConbleGatewayList* gateway);
int SqlQueryGatawayMacCount(int (*callback)(void*,int,char**,char**), int *rowCount);
int SqlQueryGatawayMac(int (*callback)(void*,int,char**,char**), FastConbleGatewayList *list);

int InitDatabase(const char *db_name);
void DeinitDatabase(void);

int SqlInsertDataInfo(FastConbleDataInfo* dataInfo);
int SqlQueryUpdateTime(char *mtag, char *updateTime);
int SqlQueryDataInfoByMtag(const char* mtag, FastConbleDataInfo* resultDataInfo);

int SqlInsertDevlist(FastConbleDevlist* devlist);

int SqlInsertFamilyInfoRoomlist(FastConbleFamilyInfoRoomlist* familyInfo);

int SqlInsertGroupList(FastConbleGroupList* group);

int SqlInsertSceneList(FastConbleSceneList* scene);

int SqlInsertSceneListModuleDev(FastConbleSceneListModuleDev *moduleDev);

int SqlCallbackRowCount(void* data, int argc, char** argv, char** azColName);
int SqlCallbackGatewayList(void* data, int argc, char** argv, char** azColName);

#endif
